<?php
require 'Admin/Model/Model.php';
	class NewsTypeModel extends Model{
		function __Construct(){
			parent::__Construct();
		}
		function getNewsTypeList(){
			$sql = "select * from news";
		    $data = $this->conn->query($sql);
			return $data;
		}
		function addNewsType($data){
			            $ntid=$_POST['ntid'];
			 			$newstype=trim($_POST['newstype']);

			  $sql = "insert into newstype values(null,'$newstype')";
			  //执行SQL语句
			 
				$result = $this->conn->query($sql);
			 	  
					return $result;
			  
		      }
		function getNewsTypeByID($id){
			$sql = "select * from newstype where ntid=".$id;
		    $result = $this->conn->query($sql);
	      	return $result;
		}

		function updateNewsType($data){
			//var_dump($data);
			$News = array(
				     'ntid' => $data['ntid'],
					
					'newstype' => trim($data['newstype']),  
					//'password' => $data['password'],
				
			  	);
			  
			 $sets = '';
			  foreach ($News as $key=>$val){
			        $sets.=$key."='".$val."',";
			  }
			    $sets=rtrim($sets,','); //去掉SQL里的最后一个逗号
			   
			    $sql="UPDATE newstype SET {$sets} where ntid=".$data['ntid'];
			  //执行SQL语句
				$result = $this->conn->query($sql);
					return $result;
			  
		}

		function delNewsType($id){
			$sql1 = "select * from newstype where ntid=".$id;
			$data1 = $this->conn->query($sql1);
			
			$sql = "delete from newstype where ntid=".$id;
			
			$result = $this->conn->query($sql);

			return $result;

		}
		function Search($data){

			$sql="select * from newstype where newstype like '%".$data."%'";
			//echo $sql;
			$result = $this->conn->query($sql);
			return $result;
		}
	}
?>